package com.mylove.judas.yaya.ui.adapter;

import android.support.v4.app.Fragment;
import android.support.v4.app.FragmentManager;
import android.support.v4.app.FragmentStatePagerAdapter;

import com.mylove.judas.yaya.common.FragmentFactory;
import com.mylove.judas.yaya.entity.FragmentInfo;
import com.mylove.judas.yaya.ui.fragment.DYTCFragment;
import com.mylove.judas.yaya.ui.fragment.MRMJFragment;
import com.mylove.judas.yaya.ui.fragment.MyPublishFragment;
import com.mylove.judas.yaya.ui.fragment.OriginalFragment;
import com.mylove.judas.yaya.ui.fragment.RecommendFragment;
import com.mylove.judas.yaya.ui.fragment.base.BaseFragment;

import java.util.ArrayList;
import java.util.List;

/**
 * Created by Judas on 2017/6/10.
 */

public class MainPagerAdapter extends FragmentStatePagerAdapter {

    private List<FragmentInfo> fragments = new ArrayList<FragmentInfo>();

    public MainPagerAdapter(FragmentManager fm) {
        super(fm);
        initFragment();
    }

    public void initFragment(){
//        fragments.add(new FragmentInfo("偶遇佳句", RecommendFragment.class));
//        fragments.add(new FragmentInfo("名人名句", MRMJFragment.class));
//        fragments.add(new FragmentInfo("电影台词", DYTCFragment.class));
//        fragments.add(new FragmentInfo("原创句子", OriginalFragment.class));
//        fragments.add(new FragmentInfo("我的发布", MyPublishFragment.class));
//        fragments.add(new FragmentInfo("全部", RecommendFragment.class));
//        fragments.add(new FragmentInfo("文字", MRMJFragment.class));
//        fragments.add(new FragmentInfo("图片", DYTCFragment.class));
//        fragments.add(new FragmentInfo("视频", OriginalFragment.class));
//        fragments.add(new FragmentInfo("我的发布", MyPublishFragment.class));

        for(int i=0; i< 6; i++){
            fragments.add(FragmentFactory.createFragmentInfo(i));
        }

    }

    @Override
    public BaseFragment getItem(int position) {

        BaseFragment bf = FragmentFactory.createFragment(fragments.get(position), position);

        return bf;
    }

    @Override
    public int getCount() {
        return fragments.size();
    }

    @Override
    public CharSequence getPageTitle(int position) {
        return fragments.get(position).getTitle();
    }
}
